import logging
# import redis
from redis import StrictRedis


class Config(object):
    # 项目的配置
    # DEBUG = True

    SECRET_KEY = 'fTlJgTonmPmbM0lTahJdQ7jLOlrHTBWUSWK0DbGfnqb598xTbTaSJRP+i3tRH0py'

    # 为数据库添加配置
    SQLALCHEMY_DATABASE_URI = 'mysql://root:mysql@127.0.0.1:3306/information27'
    SQLALCHEMY_TRACK_MODIFICATIONS = False
    # 在请求结束的时候，如果指定此配置为True, 那么SQLAlchemy会自动执行一次　db.session.commit()
    SQLALCHEMY_COMMIT_ON_TEARDOWN = True

    # redis的配置
    REDIS_HOST = '127.0.0.1'
    REDIS_POST = 6379

    # flask_session的配置信息
    SESSION_TYPE = 'redis'
    SESSION_USE_SIGNER = True
    SESSION_REDIS = StrictRedis(host=REDIS_HOST,port=REDIS_POST)
    SESSION_PERMANENT = False
    PERMANENT_SESSION_LIFETIME = 86400 * 2

    # 默认日志等级
    LOG_LEVEL = logging.DEBUG

class DevelopmentConfig(Config):
    DEBUG = True

class ProductionConfig(Config):
    DEBUG = False
    """生产模式下的配置"""
    LOG_LEVEL = logging.WARNING

class TestingConfig(Config):
    DEBUG = True
    TESTING = True

config = {
    "development":DevelopmentConfig,
    "production":ProductionConfig,
    "testing":TestingConfig
}